#pragma once
#include "OCMain/HttpClient.h"

using namespace OCPP;

void TestFTP();
void httpDownloadFile();

void TestHTTP()
{
    TestFTP();
    //httpDownloadFile();
}

void curl_log(const String& message)
{
    OCPP_LOG_INFO << message << "\n";
}

void TestFTP()
{
	OCPP_LOG_INFO << "TestHTTP\n";

    FtpClientEx ftpClient("root", "001277", curl_log);
    String url = "ftp://127.0.0.1:21/";

    String savePath = Singleton(Environment).getTmpPath();

    StringVector fileList = ftpClient.getFileList(url);
    for (auto fileName : fileList)
    {
        OCPP_LOG_INFO << U2A(fileName) << "\n";
        //if (StringUtil::endsWith(fileName, "vtk.w3dm"))
        //{
        //    ftpClient.DownloadToPath(joinPath(url, fileName), savePath);
        //}
    }
    //ftpClient.UploadFile(joinPath(url, "hzyyhrdp-service.jar"), "E:/hzyyhrdp-service.jar");
}

void httpDownloadFile()
{
    String fileName = Singleton(Environment).getTmpPath() + "image.jpeg";
    long lHTTPSCode;
    HttpClientEx httpClient(curl_log);
    httpClient.DownloadFile(fileName, "https://httpbin.org/image/jpeg", lHTTPSCode);
}